using System.Collections;
using System.Collections.Generic;

namespace SIP.PN.FrontEnd.Code
{
    public class SessionParameters
    {
        private IDictionary parameter = new Dictionary<string, object>();

        public void AddParameter(string key, object value)
        {
            if (parameter.Contains(key))
                parameter[key] = value;
            else
                parameter.Add(key, value);
        }

        public bool ContainsParameter(string key)
        {
            return parameter.Contains(key);
        }

        public T GetParameter<T>(string key)
        {
            try
            {
                if (ContainsParameter(key))
                    return (T)parameter[key];
                return default(T);
            }
            catch
            {
                return default(T);
            }

        }

        public void RemoveParameter(string key)
        {
            if (ContainsParameter(key))
                parameter.Remove(key);
        }

        public void RemoveAll()
        {
            parameter = new Dictionary<string, object>();
        }
    }
}
